import { ElMessage } from 'element-plus';

import { useI18n } from '@/hooks';

export const Message = (config) => {
  const { t } = useI18n();
  const param: any = {
    offset: 90,
    duration: 1000,
  };

  if (typeof config === 'string') {
    // 确保结果是翻译后的
    param.message = t(config);
  } else if (typeof config === 'number') {
    param.message = config;
  } else {
    Object.assign(param, config);
  }

  ElMessage(param);
};
